home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / RMTC02.ARJ / WRITEDEF.C < prev    next >
Text File  |  1992-04-06  |  743b  |  47 lines

  1. #include <stdio.h>
  2. #include <alloc.h>
  3. #include <graphics.h>
  4.  
  5. void main()
  6. {
  7.   FILE *F;
  8.   int driver = EGA;
  9.   int mode   = EGAHI;
  10.   int x, y, x2, y2, i, j;
  11.   int col;
  12.  
  13.   initgraph(&driver, &mode, "");
  14.  
  15.   setfillstyle(SOLID_FILL,BLUE);
  16.   bar(0,0,639,349);
  17.  
  18.   setfillstyle(HATCH_FILL,GREEN);
  19.   bar(0,0,30,30);
  20.   setfillstyle(SOLID_FILL,LIGHTRED);
  21.   bar(20,20,40,40);
  22.  
  23.   x=0;
  24.   y=0;
  25.   x2=40;
  26.   y2=40;
  27.  
  28.   if ((F=fopen("sample.def","w")) == NULL)
  29.   {
  30.     closegraph();
  31.     printf("Can't open file!\n");
  32.     exit(0);
  33.   }
  34.  
  35.   for (j=y;j<y2+1;j++)
  36.   {
  37.     for (i=x;i<x2+1;i++)
  38.     {
  39.       col=getpixel(i,j);
  40.       fprintf(F,"%X",col);
  41.     }
  42.     fprintf(F,"\n");
  43.   }
  44.   fclose(F);
  45.   getch();
  46.   closegraph();
  47. }